﻿using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;

using UI.WebControls.ControlsBase;
using Model.AuthModel;
using BLL.AuthModel;
namespace UI.WebControls
{
    /// <summary>
    /// UI层，页面控件基类，角色多选列表
    /// </summary>
    public class AuthModelRoles : CheckBoxListBase
    {
        public IList<StaffRolesInfo> DefaultStaffRole = new List<StaffRolesInfo>();
        /// <summary>
        /// 重载基类加载事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e) 
        {
            if (!this.Page.IsPostBack) 
            {
                IList<RolesInfo> list = new RolesBLL().ListRoles();
                if (list != null && list.Count > 0) 
                {
                    foreach (RolesInfo info in list)
                        base.Items.Add(new ListItem(info.RolesName, info.RolesID.ToString()));
                }
                if (DefaultStaffRole != null)
                {
                    foreach (StaffRolesInfo info in DefaultStaffRole)
                        base.DefaultSelect.Add(info.Roles.RolesID.ToString());
                }
            }
            base.OnLoad(e);
        }
    }
}
